package com.bwhx.eruler.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bwhx.eruler.bean.Feedback;
import com.bwhx.eruler.bean.FleeRuler;
import com.bwhx.eruler.bean.Page;
import com.bwhx.eruler.bean.Staff;
import com.bwhx.eruler.service.FleeRulerService;
/**
 * 非正常流出管理
 * @author Cuilitang
 *
 */

@Controller
public class FleeRulerController extends BaseController {
	
	@Autowired
	FleeRulerService fleerulerService;
	
	@ResponseBody
	@RequestMapping(value = "/page.everyone.fleerulerList.ashx")
	 public Map<String,Object> frList(Integer page,Integer rows,FleeRuler fr) {
		//每页的开始记录
        int start = (page-1)*rows;
        Page p = new Page(start,rows,fr);
		Map<String,Object> map = new HashMap<String,Object>();
		try{
			List<FleeRuler> list = fleerulerService.list(p);
			Integer count = fleerulerService.count(fr);
			log.info(list);
			log.info(count);
			
			map.put("total",count );//total键 存放总记录数，必须的  
			map.put("rows",list);//rows键 存放每页记录 list 
			for (FleeRuler fleeruler : list) {
				log.info(fleeruler);
			}
			
		}catch(Exception e){
			log.error(getTrace(e));
			map.put("meg", "失败！");
			map.put("status", "0");
		}
		
	    return map;  
	  }
	
	@ResponseBody
	@RequestMapping(value = "/page.updateFleeRuler.ashx")
	public String saveOrUpdateStaff(FleeRuler fleeruler,HttpSession session) {
		
		Staff staff = (Staff)session.getAttribute("staff");
		String name = staff.getsName();
		
		fleeruler.setfIsprocess(1);
		fleeruler.setfPstaff(staff.getsLoginName());
		fleeruler.setfPtime(System.currentTimeMillis()/1000);
		fleerulerService.update(fleeruler);

		
	    return "success";  
	  }
	
}
